var keyboard = new Object();
keyboard.special = new Object();
keyboard.special.move = [false, false, false, false];
keyboard.special.moveDown = false;
keyboard.special.moveUp = false;
keyboard.special.moveLeft = false;
keyboard.special.moveRight = false;

keyboard.keyDown = function(e) {
    switch(e.which) {
        case 40: // down
        case 83: // s
            game.playerEntity.moveDown();
            keyboard.special.move[0] = true;
            keyboard.special.moveDown = true;
            break;
        case 37: // left
        case 65: // a
            game.playerEntity.moveLeft();
            keyboard.special.move[1] = true;
            keyboard.special.moveLeft = true;
            break;
        case 38: // up
        case 87: // w
            game.playerEntity.moveUp();
            keyboard.special.move[2] = true;
            keyboard.special.moveUp = true;
            break;
        case 39: // right
        case 68: // d
            game.playerEntity.moveRight();
            keyboard.special.move[3] = true;
            keyboard.special.moveRight = true;
            break;
        /*
        case 32: // space // (NYI)
            isJumping = true;
            break;
        case 70: // f     // (NYI)
            showFPS = !showFPS;
            break;
        */
    }
}
keyboard.keyUp = function(e) {
    switch(e.which) {
        case 40: // down
        case 83: // s
            keyboard.special.move[0] = false;
            keyboard.special.moveDown = false;
            break;
        case 37: // left
        case 65: // a
            keyboard.special.move[1] = false;
            keyboard.special.moveLeft = false;
            break;
        case 38: // up
        case 87: // w
            keyboard.special.move[2] = false;
            keyboard.special.moveUp = false;
            break;
        case 39: // right
        case 68: // d
            keyboard.special.move[3] = false;
            keyboard.special.moveRight = false;
            break;
        /*
        case 32: // (NYI)
            isJumping = false;
            break;
        */
    }
}


// Mouse
var i_mouse = new Object();
i_mouse.scX = null;
i_mouse.scY = null;
i_mouse.x = null;
i_mouse.y = null;

// Click events
i_mouse.click = new Object();
i_mouse.click.type = null;
i_mouse.click.scX = null;
i_mouse.click.scY = null;
i_mouse.click.x = null;
i_mouse.click.y = null;

i_mouse.move = function(e) {
    i_mouse.scX = e.pageX;
    i_mouse.scY = e.pageY;
    
    // Game window relative
    var GWOffset = $bgCanvas.offset();
    i_mouse.x = i_mouse.scX - GWOffset.left;
    i_mouse.y = i_mouse.scY - GWOffset.top;
}

i_mouse.down = function(e) {
    i_mouse.click.scX = e.pageX;
    i_mouse.click.scY = e.pageY;
    i_mouse.click.type = e.which;
    
    // Game window relative
    var GWOffset = $bgCanvas.offset();
    i_mouse.click.x = i_mouse.click.scX - GWOffset.left;
    i_mouse.click.y = i_mouse.click.scY - GWOffset.top;
}